﻿/*
 * ========================================================================
 * Copyright(c) 2007-2012 情留メ蚊子, All Rights Reserved.
 * Welcom use the LiteFetion.
 * See more information,Please goto http://www.94qing.com
 * ========================================================================
 * 
 * 作 者：情留メ蚊子
 * Q  Q: 540644769
 * 邮 箱：qlwz@qq.com
 * 网 址：http://www.94qing.com
 * ========================================================================
*/
using LiteFetion.Model;
using Newtonsoft.Json.Linq;

namespace LiteFetion.Notify
{
    /// <summary>
    /// 添加好友回复
    /// </summary>
    public class BuddyConfirmedNotify
    {
        public BuddyConfirmedNotify(FetionClient client, JObject data)
        {
            this.FetionClient = client;
            this.IsAgreed = false;
            int userId = data.Value<int>("uid");
            this.Buddy = this.FetionClient.BuddyManager.GetBuddyByUserId(userId);
            if (this.Buddy != null)
            {
                this.Buddy.Relation = Buddy.GetRelation(data.Value<int>("rs"));
                this.IsAgreed = (this.Buddy.Relation == Relation.BUDDY);
                Event.OnBuddyConfirmedNotify(this);
            }
        }

        /// <summary>
        /// FetionClient
        /// </summary>
        public FetionClient FetionClient { get; private set; }

        /// <summary>
        /// 好友对象
        /// </summary>
        public Buddy Buddy { get; private set; }

        /// <summary>
        /// 是否同意
        /// </summary>
        public bool IsAgreed { get; private set; }

        public override string ToString()
        {
            return "BuddyConfirmedNotify [Buddy=" + this.Buddy.DisplayName + ", IsAgreed=" + this.IsAgreed + "]";
        }
    }
}
